Skip to content

feat: Add ContractLog data model and repository interface#75

Open
Twiineenock wants to merge 1 commit intohiero-ledger:mainfrom
Twiineenock:feature/smart-contract-logs-api
Open

feat: Add ContractLog data model and repository interface#75
Twiineenock wants to merge 1 commit intohiero-ledger:mainfrom
Twiineenock:feature/smart-contract-logs-api

Conversation

@Twiineenock
Copy link
Copy Markdown
Contributor

Description

This PR addresses the first phase of the proposed solution in the linked issue by establishing the core data model and repository interface for the Smart Contract Event and Log API.

To ensure the review process is clean and manageable for mentors, the implementation is being split into logical PRs. This PR specifically focuses on the public API surface:

  • Introduces the ContractLog record, meticulously mapped to the EVM event log format returned by the Hiero Mirror Node (handling fields like topics, data, and mapping consensus_timestamp to Java's Instant).
  • Introduces the ContractLogRepository interface to provide a high-level abstraction for querying logs by ContractId.

Subsequent PRs will introduce the base module implementations, followed by the framework-native (Spring Boot/MicroProfile) JSON parsers and pagination handlers.

Related issue(s)

Fixes #74

NB

  • Data models prioritize immutability (topics list is wrapped in List.copyOf()) and strict null-safety using org.jspecify.annotations.

This commit introduces the core data model (ContractLog) and the ContractLogRepository interface to support querying smart contract events from the Hiero Mirror Node. This establishes the public API surface for the feature, and is aligned strictly with the Hedera Mirror Node REST API JSON responses.

Signed-off-by: Twiineenock <Twiineenock@users.noreply.github.com>
@Twiineenock Twiineenock force-pushed the feature/smart-contract-logs-api branch from 2cd3014 to 51023e9 Compare April 23, 2026 06:19
@Twiineenock
Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should ContractLog align more closely with the existing ContractResult DTO? Both model Mirror Node contract endpoints, and ContractResult keeps EVM/Mirror metadata fields like contractId, blockHash, blockNumber, and transactionIndex nullable/boxed while using the Mirror field name timestamp. Matching that shape here would make the contract DTOs more consistent and avoid requiring fields that Mirror responses may omit or return as null.

Copy link
Copy Markdown
Contributor

@alejandroGM0 alejandroGM0 Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should probably be part of ContractRepository rather than a separate ContractLogRepository. Existing repository APIs appear to group Mirror Node reads around the parent domain object, for example TopicRepository owns both topic lookup and topic messages. Since these logs are contract-scoped and queried by ContractId, exposing them alongside the other contract reads would make the API more consistent.

@alejandroGM0
Copy link
Copy Markdown
Contributor

I had similar work in progress before this PR (contract results/logs + Spring/MicroProfile wiring + converters/tests). Happy to wait for this to merge and then contribute my implementation as a follow-up PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Smart Contract Event and Log Observation API

2 participants